package core

import (
	"fmt"
	"gopkg.in/yaml.v3"
	"log"
	"os"
	"wecom_rebot/common"
	"wecom_rebot/config"
)

const ConfigFile = "settings.yaml"

// YamlInitConfig 读取 settings.yaml 文件里面的配置信息
func YamlInitConfig() {
	c := &config.Config{}
	yamlConfig, err := os.ReadFile(ConfigFile)
	if err != nil {
		panic(fmt.Errorf("get yamlConfig error: %s", err))
	}
	err = yaml.Unmarshal(yamlConfig, c)
	if err != nil {
		log.Fatalf("config Init Unmarshal error: %v", err)
	}
	log.Println("config yamlFile load Init success.")
	common.Config = c
}
